<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<script type="text/javascript">
	
	//添加画报主题
	function addPictorialTopic(){
		var name = $("#name").val();
		var description = $("#description").val();
		if($.trim(name)==""){
			$.ligerDialog.warn("请输入画报主题名称");
			return;
		}
		if(description.length > 500){
			$.ligerDialog.warn("画报简介不能超过500个字");
			return;
		}
		var isLock = ($("#isLock").val()==1);
		var image1 =  $("#image1").attr("src");
		var image2 =  $("#image2").attr("src");
		var image3 =  $("#image3").attr("src");
		var sort = $("#sort").val();
		$.post("/misc/tag/updatePictorialTopic.htm",{
			identifier : '${pictorial.identifier}',
			name : $.trim(name),
			isLock : isLock,
			description : $.trim(description),
			image1 : image1,
			image2 : image2,
			image3 : image3,
			sort : sort
		},function(data){
			if(data=="same"){
				alert("亲，这个画报主题名称已存在，您还是换一个吧！");
				$("#name").select();
			}else if(data=="success"){
				$("#name").val("");
				$("#description").val("");
				parent.topicGrid.loadData();
				parent.$.ligerDialog.success("编辑成功！");
				parent.topicDialog.close();
			}else{
				$.ligerDialog.warn("由于系统抽经，刚才的操作不成功，请稍候再试");
			}
		});
	}
	
	//上传图片
	function uploadImg(self) {
		var filepath = $(self).val();
		var extStart = filepath.lastIndexOf(".");
		var ext = filepath.substring(extStart, filepath.length).toUpperCase();
		if (ext != ".PNG" && ext != ".JPG" && ext != ".JPEG" && ext != ".GIF") {
			alert("图片限于png,jpeg,jpg,gif格式");
			return;
		}
		$(self).parent().ajaxSubmit({
			dataType : 'json',
			cache : false,
			success : function(data) {
				$(self).parent().parent().find(".imagec").attr("src",data.imageServer+data.pictureUrl);
			},
			error : function(err) {
				alert(err);
			}
		});
		return false;
	}
	
</script>
<table width="100%" class="def_t">
	<tr>
		<td>画报主题名称：</td>
		<td><input type="text" id="name" style="width: 318px;" value="${pictorial.name}" /><font color="red">*</font></td>
	</tr>
	<tr>
		<td>排序：</td>
		<td><input type="text" id="sort" style="width: 318px;" value="${pictorial.sort}" /></td>
	</tr>
	<tr>
		<td>首推列表图片：</td>
		<td>
			<form enctype="multipart/form-data" method="post" action="/misc/cms/backgroundImgUpload.htm"
				style="display: block;">
				<input type="file" onchange="uploadImg(this);return false;"
					class="input_file" title="支持jpg、jpeg、gif、png格式，文件小于5M" name="image1" />
				<input type="hidden" name="contentId" value="pictorialTopic">
				<img src="${pictorial.image1}" id="image1" class="imagec">
			</form>
		</td>
	</tr>
	<tr>
		<td>列表图片：</td>
		<td>
			
			<form enctype="multipart/form-data" method="post" action="/misc/cms/backgroundImgUpload.htm"
				style="display: block;">
				<input type="file" onchange="uploadImg(this);return false;"
					class="input_file" title="支持jpg、jpeg、gif、png格式，文件小于5M" name="image2" />
				<input type="hidden" name="contentId" value="pictorialTopic">
				<img src="${pictorial.image2}" id="image2" class="imagec">
			</form>
		</td>
	</tr>
	<tr>
		<td>内页图片：</td>
		<td><form enctype="multipart/form-data" method="post" action="/misc/cms/backgroundImgUpload.htm"
				style="display: block;">
				<input type="file" onchange="uploadImg(this);return false;"
					class="input_file" title="支持jpg、jpeg、gif、png格式，文件小于5M" name="image3" />
				<input type="hidden" name="contentId" value="pictorialTopic">
				<img src="${pictorial.image3}" id="image3" class="imagec">
			</form></td>
	</tr>
	<tr>
		<td>是否撤销：</td>
		<td>
			<select id="isLock">
				<option value="0" <c:if test="${!pictorial.isLock}">SELECTED</c:if>>否</option>
				<option value="1" <c:if test="${pictorial.isLock}">SELECTED</c:if>>是</option>
			</select>
		</td>
	</tr>
	<tr>
		<td>画报主题简介：</td>
		<td><textarea name="description" id="description" style="width: 318px;height: 200px;">${pictorial.description}</textarea></td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			<button onclick="addPictorialTopic()" style="cursor: pointer;">保存</button>
		</td>
	</tr>
</table>
